<?
/**
* Copyright (c) 2002-2007 BioWare Corp.
* http://www.bigdaddymonitor.org
*
* This file is part of the BigDaddy Monitoring
* program. It is free software distributed under
* the terms of the BSD License. It is ditributed
* in the hopes that it will be useful, but
* WITHOUT ANY WARRANTY; without event the implied
* warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE.
*
* The BSD License is available from:
* http://www.opensource.org/licenses/bsd-license.php
**/
//=============================================================//
//Query File for Server Group Control (BigDaddy v3)
//Duleepa Wijyawardhana, 17.04.2006
//=============================================================//

switch($_REQUEST["action"])
{
    case "addservergroup":
		$aInfo["groupname"] = $_POST["groupname"];
		$aInfo["iniID"] = $_POST["iniID"];
		$aInfo["mon_startlevel"] = $_POST["mon_startlevel"];
		$aInfo["mon_percentthreshold"] = $_POST["mon_percentthreshold"];
		$aInfo["mon_numberthreshold"] = $_POST["mon_numberthreshold"];
		$aInfo["mon_endlevel"] = $_POST["mon_endlevel"];
		$aInfo["notes"] = $_POST["notes"];
		
		$nInsertID = $BigDaddyControl->SetServerGroup($aInfo);
		$redirectTo="page=ServerGroupViewDetails&serverGroupID=".$nInsertID;
        
        break;
    case "editservergroup":
        $aInfo["groupname"] = $_POST["groupname"];
		$aInfo["iniID"] = $_POST["iniID"];
		$aInfo["mon_startlevel"] = $_POST["mon_startlevel"];
		$aInfo["mon_endlevel"] = $_POST["mon_endlevel"];
		$aInfo["mon_percentthreshold"] = $_POST["mon_percentthreshold"];
		$aInfo["mon_numberthreshold"] = $_POST["mon_numberthreshold"];
		$aInfo["notes"] = $_POST["notes"];
		
		$BigDaddyControl->SetServerGroup($aInfo, $_POST["serverGroupID"]);
		$redirectTo="page=ServerGroupViewDetails&serverGroupID=".$_POST["serverGroupID"];
        break;
	case "addmod":
		$BigDaddyControl->SetServerGroupModule($_POST["serverModuleID"], $_POST["serverGroupID"]);
		$redirectTo="page=ServerGroupViewDetails&serverGroupID=".$_POST["serverGroupID"];
		break;
	case "deletemodfromgroup":
		$BigDaddyControl->RemoveServerGroupModule($_REQUEST["serverModuleID"], $_REQUEST["serverGroupID"]);
		$redirectTo="page=ServerGroupViewDetails&serverGroupID=".$_REQUEST["serverGroupID"];
		break;
    case "enableservergroup":
        if ($_REQUEST["serverGroupID"]>0)
        {
			$BigDaddyControl->SetServerGroupStatusToEnabled($_REQUEST["serverGroupID"]);
            $redirectTo=$_SESSION["sessdata"]["pagefrom"];
        }
        break;
    case "disableservergroup":
        if ($_REQUEST["serverGroupID"]>0)
        {
			$BigDaddyControl->SetServerGroupStatusToDisabled($_REQUEST["serverGroupID"]);
            $redirectTo=$_SESSION["sessdata"]["pagefrom"];
        }
        break;
    case "deleteservergroup":
        if ($_REQUEST["serverGroupID"]>0)
        {
			$BigDaddyControl->RemoveServerGroup($_REQUEST["serverGroupID"]);
            $redirectTo="page=ServerGroupIndex";
        }
        break;
	case "delaygroup":
        if ($_REQUEST["serverGroupID"]>0)
        {
            $delayUntil=mktime($_POST["hourselect"],$_POST["minuteselect"], 0, $_POST["monthselect"], $_POST["dayselect"], $_POST["yearselect"]);
			$BigDaddyControl->SetServerGroupDelay($_REQUEST["serverGroupID"], $delayUntil);
            $redirectTo=$_SESSION["sessdata"]["pagefrom"];
        }
        break;
   
}

if ($redirectTo!="")
{
	
	
    header("Location: /index.html?".$redirectTo);
    exit;
}
else
{
    header("Location: /index.html");
    exit;
}

?>
